﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using CoreInmobiliario.Data;

namespace CoreInmobiliario.Business
{
    [DataObject]
    public class Disposicion
    {
        public static Disposicion GetInstance()
        {
            return new Disposicion();
        }

        private static DBDataContext GetDBDataContext()
        {
            Factories.DBDataContextFactory factory = new Factories.DBDataContextFactory();
            return factory.CreateDataContext() as DBDataContext;
        }

        public Data.Disposicion GetById(int disposicionId)
        {
            Data.Disposicion disposicion = null;

            using (DBDataContext dataContext = GetDBDataContext())
            {
                try
                {
                    disposicion = dataContext.Disposicions.FirstOrDefault(d => d.DisposicionId.Equals(disposicionId));
                }
                catch (Exception ex)
                {

                }
            }
            return disposicion;
        }

        public List<Data.Disposicion> GetList()
        {
            List<Data.Disposicion> list = null;

            using (DBDataContext dataContext = GetDBDataContext())
            {
                try
                {
                    list = dataContext.Disposicions.ToList();

                }
                catch (Exception ex)
                {

                }
            }
            return list;
        }
    }
}
